package com.atguigu.spzx.manner.service.impl;

import com.atguigu.spzx.manner.mapper.SysRoleMapper;
import com.atguigu.spzx.manner.service.SysRoleService;
import com.atguigu.spzx.model.dto.AssginRoleDto;
import com.atguigu.spzx.model.dto.SysRoleDto;
import com.atguigu.spzx.model.entity.SysRole;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysRoleServiceImpl implements SysRoleService {
    @Autowired
    SysRoleMapper sysRoleMapper;
    @Override
    public PageInfo<SysRole> findByPage(Integer pageNum, Integer pageSize, SysRoleDto sysRoleDto) {
       PageHelper.startPage(pageNum, pageSize);
        List<SysRole> roleList = sysRoleMapper.selectfindByPage(sysRoleDto);

        return new PageInfo<>(roleList);
    }

    @Override
    public void updateSysRole(SysRole sysRole) {
        sysRoleMapper.updateByPrimaryKeySelective(sysRole);
    }

    @Override
    public void saveSysRole(SysRole sysRole) {
        sysRoleMapper.insertSysRole(sysRole);
    }

    @Override
    public void delete(Long id) {
        sysRoleMapper.deleteByPrimaryKey(id);
    }

    @Override
    public List<SysRole> findAllRoles() {
        return sysRoleMapper.selectFindAllRoles();
    }

    @Override
    public List<Long> findAllRolesById(Integer id) {
        return sysRoleMapper.selectFindAllRolesById(id);

    }

    @Override
    public void doAssign(AssginRoleDto assginRoleDto) {

    }
}
